<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 17-2-27
 * Time: 上午10:13
 */

class Foo
{
    public static $my_static = 'foo';

    public function staticValue() {
        return self::$my_static;
    }
}

class Bar extends Foo
{
    public function fooStatic() {
        return parent::$my_static;
    }
}



echo str_repeat("*",20).PHP_EOL;
print Foo::$my_static . "\n";
echo str_repeat("*",20).PHP_EOL;

$foo = new Foo();
print $foo->staticValue() . "\n";
//print $foo->my_static . "\n";      // Undefined "Property" my_static

print $foo::$my_static . "\n";
$classname = 'Foo';
print $classname::$my_static . "\n"; // As of PHP 5.3.0

print Bar::$my_static . "\n";
$bar = new Bar();
print $bar->fooStatic() . "\n";


class MyParent {

    protected static $variable;
}

class Child1 extends MyParent {

//    protected static $variable;
    function set() {

        self::$variable = 2;
    }
}

class Child2 extends MyParent {

    function show() {

        echo(self::$variable);
    }
}
echo str_repeat("*",20).PHP_EOL;

$c1 = new Child1();
$c1->set();
$c2 = new Child2();
$c2->show(); // prints 2


class a {

    public function get () {
        echo $this->connect();
    }
}
class b extends a {
    private static $a;

    public function connect() {
        return self::$a = 'b';
    }
}
class c extends a {
    private static $a;

    public function connect() {
        return self::$a = 'c';
    }
}
echo str_repeat("*",20).PHP_EOL;

$b = new b ();
$c = new c ();

$b->get();
$c->get();



class Singleton {}